<template>
	<view>
		<view class="search">
			<u-search margin="20rpx" shape="square" :showAction="isshow"></u-search>
		</view>
		<view class="box">
			<view class="leftbox">
				<ul>
					<li v-for="(item,index) in list" :key="item.id" @click="toggle(index)"> {{item.catename}}</li>
				</ul>
			</view>
			<view class="rightbox">
				<view class="content">
					<ul>
						<li v-for="item in contents" :key="item.id" @click="goodslist(item.id)">
							<view class="contop">
								<view class="">
									<image :src="baseUrl+item.img"></image>
								</view>
								<view class="">
									<text class="text">{{item.catename}}</text>
								</view>
							</view>
							<view class="conbottom">

							</view>
						</li>
					</ul>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		getCates
	} from "@/request/app.js"
	export default {
		data() {
			return {
				isshow: false,
				list: [],
				contents: [],
				baseUrl: this.$imgUrl
		}
		},
		onLoad(){
			getCates()
			.then(res=>{
				// console.log(res); 
				this.list = res.data.list
				this.contents = this.list[0].children
				console.log(this.contents) 
			})
		},
		methods:{
			toggle(e) {
				// console.log(this.list[e]);
				this.contents = this.list[e].children
				// console.log(this.contents);
			},
			// 点击商品跳列表
			goodslist(e){
				console.log(e,"2");
				 uni.navigateTo({
				 	url:'../list/list?id='+e
				 })
			}
		}
	}
</script>

<style>
	.search {
		width: 100%;
		background-color: #FF6040;
		height: 120rpx;
		overflow: hidden;
		box-sizing: border-box;
	}

	.leftbox {
		width: 30%;
		background-color: #fff;
		float: left;
		text-align: center;
	}

	.leftbox ul li {
		height: 90rpx;
		line-height: 90rpx;
		color: #999;
	}

	.rightbox {
		width: 70%;
		height: auto;
		background-color: #eee;
		float: right;
		box-sizing: border-box;
		padding: 20rpx;
	}

	.content {
		width: 100%;
		height: auto;
		background-color: #FFf;
	}

	.content ul li {
		width: 25%;
		padding: 10rpx;
		background-color: #fff;
		float: left;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
	}

	.contop image {
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
	}

	.contop {
		text-align: center;
	}

	.text {
		font-size: 25rpx;
	}
</style>
